package cn.yanjr.system.dao.impl;

import java.util.List;

import cn.yanjr.common.dao.BaseDaoImpl;
import cn.yanjr.system.dao.SysMenuDao;
import cn.yanjr.system.entity.SysMenu;

public class SysMenuDaoImpl extends BaseDaoImpl<String, SysMenu> implements SysMenuDao {
	
	@Override
	public List<SysMenu> findAll() {
		String sql = "select * from sys_menu m where m.del_flag=0";
		List<SysMenu> list = findEntitys(sql);
		return list;
	}
	
	@Override
	public List<SysMenu> findAll(SysMenu menu) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public SysMenu findOne(String id) {
		String sql = "select * from sys_menu where id=?";
		SysMenu area = null;
		area = findFirstEntity(sql, id);
		return area;
	}

	@Override
	public int save(SysMenu menu) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int update(SysMenu menu) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(String id) {
		String sql = "delete from sys_menu  where id=? ";
		return update(sql.toString(), id);
	}


	@Override
	public List<SysMenu> getMenusByUserIdAndStatusId(String userId, int statusId) {
		String sql = "select distinct m.* from sys_menu m            "
				+ "join sys_role_menu rm on m.id=rm.menu_id       "
				+ "join sys_user_role ur on ur.role_id=rm.role_id "
				+ "where ur.user_id=? and m.status_id<=? and m.del_flag=0 "
				+ "order by m.parent_id, m.sort                   "
				;
		List<SysMenu> list = findEntitys(sql, userId, statusId);
		return list;
	}
	
	@Override
	public List<SysMenu> getMenusByRoleId(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int deleteRoleMenuByRoleId(String roleId) {
		// TODO Auto-generated method stub
		return 0;
	}



}
